package com.wehealth;


import android.util.Log;
import android.support.v4.app.Fragment;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.umeng.analytics.MobclickAgent;
import com.wehealth.Dr_List;
import com.wehealth.Dr_Free;

public class Dr_Select extends Fragment {
	
	private static final int FREE_CONSULT = 1;
	private Context context;
	
	public  Dr_Select()
	{
		Log.i("init:", "test"); 
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		return  inflater.inflate(R.layout.dr_select, null);
	}
	
	public void onActivityCreated(Bundle savedInstanceState){
		
		super.onActivityCreated(savedInstanceState);
		
		Log.i("OnActivityCreated:", "test"); 
		
		MainActivity activity = (MainActivity)getActivity();
		context = activity;
		MobclickAgent.openActivityDurationTrack(false);
		 Button bBack = (Button) activity.findViewById(R.id.b_back);
			
		 bBack.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
					
                    MainActivity activity = (MainActivity) getActivity();                       
                    activity.switchContentHome();
					
					Log.i("back home", " from: dr_select"); 
				}
			});
		 
		 
		 Button bSel1 = (Button) activity.findViewById(R.id.bDrSelect1);
			
		 bSel1.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
					Log.d("SIMMON","  bSel1 ");
					//SIMMON_ADD
					ConsultationQestion cons = new ConsultationQestion(null,FREE_CONSULT);
					
					if (getActivity() instanceof MainActivity)
					{
						MainActivity activity = (MainActivity) getActivity();
						
						activity.switchContent(cons);
					}
					
					
				}
			});
		 
		 Button bSel2 = (Button) activity.findViewById(R.id.bDrSelect2);
			
		 bSel2.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
				
					Dr_List drList = new Dr_List();
					
					if (getActivity() instanceof MainActivity)
					{
						MainActivity activity = (MainActivity) getActivity();
						
						activity.switchContent(drList);
					}
					
					
				}
			});
		 
		 Button bSel3 = (Button) activity.findViewById(R.id.bDrSelect3);
			
		 bSel3.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
				
					openDialog();
					
				}
			});
			
		
	}
	
	private void openDialog(){
		
	    AlertDialog.Builder builder = new AlertDialog.Builder(context);    
	    builder.setTitle("功能暂时没有开通！");  
	    builder.setPositiveButton("知道了",null);
	    builder.show();  
		
	}
	
    @Override
    public void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        MobclickAgent.onPageEnd("Dr_Select"); 
    }


    @Override
    public void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        MobclickAgent.onPageStart("Dr_Select"); 
    }
	

}
